Skip to content

feat(cli): add async server wait workflow - #410

Merged
xizhibei merged 5 commits into
mainfrom
codex/issues-async-395-405
Aug 2, 2026
Merged

feat(cli): add async server wait workflow#410
xizhibei merged 5 commits into
mainfrom
codex/issues-async-395-405

Conversation

@xizhibei

@xizhibei xizhibei commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • expose deterministic startup loading states through authenticated, filtered inspect responses
  • add 1mcp wait [server] and status-aware run behavior that never falls through to an unsafe early MCP session
  • correct async-startup guidance and add matching English/Chinese command documentation

Validation

  • pnpm lint
  • pnpm typecheck
  • pnpm build
  • pnpm docs:build
  • pnpm test:unit (298 files, 4,333 tests)

Existing Vitest mock-hoisting, VitePress highlighting/chunk-size, and Node deprecation warnings remain unchanged.

Closes #395
Closes #405

Summary by CodeRabbit

  • New Features

    • Added a wait CLI command to monitor configured static servers until they are connected and available.
    • Added structured status reporting for loading, authorization, failure, and timeout states.
    • Enhanced run and inspect workflows with clearer server readiness and recovery guidance.
    • Added text, JSON, and TOON output options for wait results.
  • Documentation

    • Added English and Chinese documentation for wait.
    • Updated startup, inspection, and run workflow guidance for asynchronous loading and status checks.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This change adds load-aware inspect status contracts, a new wait CLI workflow, REST readiness checks for run, updated output schemas and formatting, HTTP coverage, and English and Chinese documentation for asynchronous server loading.

Changes

Async loading workflow

Layer / File(s) Summary
Status contracts and inspect query plumbing
src/types/serverStatus.ts, src/commands/shared/inspectApiSchemas.ts, src/commands/shared/filterSelectionQuery.ts, src/commands/shared/apiClient.ts, src/commands/inspect/*
Adds shared server statuses, inspect schemas, reusable filter query construction, request-scoped GET options, and load-related inspect output fields.
Loading-aware inspect endpoint
src/transport/http/routes/inspectHelpers.ts, src/transport/http/routes/inspectRoutes.ts, src/transport/http/routes/*test.ts
Inspect responses now include loading-prioritized state, tracked-server metadata, availability, authorization details, errors, and empty tool inventories before readiness.
Wait command and CLI wiring
src/commands/wait/*, src/commands/shared/clientSurfaceAttachment.ts, src/commands/shared/commandRunner.ts, src/commands/instructions/instructionsUtils.ts, src/index.ts
Adds 1mcp wait [server] with polling, filtering, timeout and terminal-state handling, structured output, REST retry behavior, and instruction updates.
Run REST readiness checks
src/commands/run/run.ts, src/commands/run/*.test.ts
run checks inspect status before REST-to-MCP fallback, reports loading or unavailable states, and validates filtered tool responses with shared schemas.
Async loading and CLI workflow documentation
README.md, docs/en/..., docs/zh/..., docs/.vitepress/config/*
Documents asynchronous catalog publication, authenticated inspect status, wait and run behavior, health endpoints, and English and Chinese wait navigation and pages.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI as wait CLI
  participant Surface as Reusable client surface
  participant Inspect as /api/v1/inspect
  participant Runtime as Loading tracker
  CLI->>Surface: start authenticated wait workflow
  Surface->>Inspect: poll tracked server status
  Inspect->>Runtime: read loading state
  Runtime-->>Inspect: return status and availability
  Inspect-->>CLI: return connected, terminal, or timeout result
Loading

Possibly related PRs

  • 1mcp-app/agent#282: Provides the CLI mode and shared command plumbing extended by this workflow.
  • 1mcp-app/agent#326: Provides the reusable client-surface architecture extended for wait and forced REST checks.
  • 1mcp-app/agent#332: Provides loading-manager behavior surfaced through inspect status fields.

Poem

A rabbit polls beneath the moon,
“Connected servers will arrive soon!”
With wait and status neatly shown,
REST guards tools before they’re known.
Hop, hop—the catalog blooms!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.08% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change: adding an asynchronous server wait workflow to the CLI.
Linked Issues check ✅ Passed The implementation and documentation satisfy the linked status, wait, run-safety, filtering, output, instruction, and bilingual documentation objectives [#395, #405].
Out of Scope Changes check ✅ Passed The code, tests, CLI registration, API changes, and documentation directly support the linked async loading and wait workflow objectives.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/issues-async-395-405

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (2)
docs/zh/commands/inspect.md (1)

21-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Bring the edited public command pages into the documentation contract.

  • docs/zh/commands/inspect.md#L21-L21: Add frontmatter and replace ./wait.md with the absolute /zh/commands/wait link.
  • docs/zh/commands/run.md#L23-L23: Add required frontmatter.

As per coding guidelines, “Include frontmatter for all public documentation pages” and “Use absolute internal links in documentation.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/zh/commands/inspect.md` at line 21, Update docs/zh/commands/inspect.md
at lines 21-21 by adding the required frontmatter and replacing the relative
./wait.md link with the absolute /zh/commands/wait link. Update
docs/zh/commands/run.md at lines 23-23 by adding the required frontmatter,
following the existing public documentation page conventions.

Source: Coding guidelines

src/commands/shared/clientSurfaceAttachment.test.ts (1)

194-215: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the shared mock factories for the new test fixtures.

  • src/commands/shared/clientSurfaceAttachment.test.ts#L194-L215: Create the cached-session fixture through test/unit-utils/MockFactories.ts, extending it if needed.
  • src/commands/wait/wait.test.ts#L7-L39: Create the attachment context and inspect-response fixture data through the shared factories.

As per coding guidelines, “Use test/unit-utils/MockFactories.ts for consistent mock data and mock factories.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands/shared/clientSurfaceAttachment.test.ts` around lines 194 - 215,
Use the shared mock factories from test/unit-utils/MockFactories.ts for both
affected test fixtures: in src/commands/shared/clientSurfaceAttachment.test.ts
lines 194-215, create the cached-session data through the appropriate factory
and extend it with required fields; in src/commands/wait/wait.test.ts lines
7-39, create the attachment context and inspect-response data through the shared
factories. Preserve each test’s existing behavior and assertions.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/en/commands/index.md`:
- Line 82: Update docs/en/commands/index.md lines 82-82 to describe wait as
waiting for configured static servers to become connected and available. Update
docs/en/commands/inspect.md lines 36-36 to state that scripts wait for servers
to be connected and available, and replace the relative ./wait.md link with the
absolute internal /commands/wait link.

In `@docs/en/guide/advanced/fast-startup.md`:
- Line 65: Update the readiness descriptions for the connected state in
docs/en/guide/advanced/fast-startup.md lines 65-65 and
docs/zh/guide/advanced/fast-startup.md lines 65-65 to clarify that tool
invocation requires both connected and available, not connected alone; preserve
the respective English and Chinese wording.

In `@src/commands/run/run.ts`:
- Around line 256-334: Update the status dispatch around the existing
connected-and-available check to explicitly handle server.status === 'connected'
with server.available === false. Route this transitional state through
statusErrorResponse using server_loading semantics, with guidance to wait for
the server to become available rather than suggesting a restart; leave the
existing pending/loading, OAuth, and generic unavailable branches unchanged.

In `@src/commands/wait/wait.ts`:
- Around line 69-70: Update the status handling around the wait command’s
attachment check to handle auth_required separately, preserving its original
error code and the context-aware recovery guidance from
formatClientSurfaceAuthRequiredMessage. Only non-authentication failures should
continue throwing server_status_unavailable with 1mcp inspect.
- Around line 47-55: Update waitCommand to validate and normalize the complete
WaitCommandOptions object with the project’s Zod schema before reading timeout
or starting attachment/polling. Include timeout, filter/tag, and format fields
in the boundary validation, then use the parsed options for subsequent logic
while preserving the existing positive-timeout requirement and WaitCommandError
behavior.

In `@src/transport/http/routes/inspectRoutes.ts`:
- Around line 435-454: Apply the same target authorization or scope gate used
for tool targets before the static-server early return in the inspect route.
Ensure out-of-scope static servers return 404 before exposing status,
authorizationUrl, or error metadata, while preserving the existing payload for
authorized static servers.

---

Nitpick comments:
In `@docs/zh/commands/inspect.md`:
- Line 21: Update docs/zh/commands/inspect.md at lines 21-21 by adding the
required frontmatter and replacing the relative ./wait.md link with the absolute
/zh/commands/wait link. Update docs/zh/commands/run.md at lines 23-23 by adding
the required frontmatter, following the existing public documentation page
conventions.

In `@src/commands/shared/clientSurfaceAttachment.test.ts`:
- Around line 194-215: Use the shared mock factories from
test/unit-utils/MockFactories.ts for both affected test fixtures: in
src/commands/shared/clientSurfaceAttachment.test.ts lines 194-215, create the
cached-session data through the appropriate factory and extend it with required
fields; in src/commands/wait/wait.test.ts lines 7-39, create the attachment
context and inspect-response data through the shared factories. Preserve each
test’s existing behavior and assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7566ba78-fdb3-4ec3-982b-cbde8db4b728

📥 Commits

Reviewing files that changed from the base of the PR and between d31877a and 780bbe3.

📒 Files selected for processing (36)
  • README.md
  • docs/.vitepress/config/en.ts
  • docs/.vitepress/config/zh.ts
  • docs/en/commands/index.md
  • docs/en/commands/inspect.md
  • docs/en/commands/run.md
  • docs/en/commands/wait.md
  • docs/en/guide/advanced/fast-startup.md
  • docs/zh/commands/index.md
  • docs/zh/commands/inspect.md
  • docs/zh/commands/run.md
  • docs/zh/commands/wait.md
  • docs/zh/guide/advanced/fast-startup.md
  • src/commands/inspect/inspect.ts
  • src/commands/inspect/inspectUtils.ts
  • src/commands/instructions/instructionsUtils.ts
  • src/commands/run/run.rest-errors.test.ts
  • src/commands/run/run.rest-fallback.test.ts
  • src/commands/run/run.rest-primary.test.ts
  • src/commands/run/run.ts
  • src/commands/shared/apiClient.ts
  • src/commands/shared/clientSurfaceAttachment.test.ts
  • src/commands/shared/clientSurfaceAttachment.ts
  • src/commands/shared/commandRunner.test.ts
  • src/commands/shared/commandRunner.ts
  • src/commands/shared/filterSelectionQuery.ts
  • src/commands/shared/inspectApiSchemas.ts
  • src/commands/wait/index.ts
  • src/commands/wait/wait.test.ts
  • src/commands/wait/wait.ts
  • src/index.ts
  • src/transport/http/routes/apiRoutes.test.ts
  • src/transport/http/routes/inspectHelpers.test.ts
  • src/transport/http/routes/inspectHelpers.ts
  • src/transport/http/routes/inspectRoutes.ts
  • src/types/serverStatus.ts

Comment thread docs/en/commands/index.md Outdated
Comment thread docs/en/guide/advanced/fast-startup.md Outdated
Comment thread src/commands/run/run.ts
Comment thread src/commands/wait/wait.ts
Comment thread src/commands/wait/wait.ts
Comment thread src/transport/http/routes/inspectRoutes.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/zh/guide/advanced/fast-startup.md (1)

59-71: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Remove the misleading loading section timeout reference.

The deprecation row says asyncLoading.timeout is a no-op, but the next “Configuration” sentence re‑introduces a non-existent JSON loading timeout path. Keep the section focused on asyncLoading.batchDelay/--async-batch-delay, and remove or rewrite the timeout example so users do not configure a timeout that has no effect.

Do the same change in the parallel English page.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/zh/guide/advanced/fast-startup.md` around lines 59 - 71, Update the “配置”
guidance in the Chinese fast-startup documentation and its parallel English page
to remove the misleading JSON loading timeout reference. Keep the section
focused on the supported async loading settings, especially
asyncLoading.batchDelay and --async-batch-delay, and do not suggest configuring
the deprecated no-op asyncLoading.timeout.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/zh/guide/advanced/fast-startup.md`:
- Line 73: Update the internal configuration link in the Chinese fast-startup
guide to use the `/zh/` locale prefix, while preserving the existing
configuration section anchor and link text.

---

Outside diff comments:
In `@docs/zh/guide/advanced/fast-startup.md`:
- Around line 59-71: Update the “配置” guidance in the Chinese fast-startup
documentation and its parallel English page to remove the misleading JSON
loading timeout reference. Keep the section focused on the supported async
loading settings, especially asyncLoading.batchDelay and --async-batch-delay,
and do not suggest configuring the deprecated no-op asyncLoading.timeout.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ea97f59e-2bb9-40eb-b1d8-74ab455eb1b1

📥 Commits

Reviewing files that changed from the base of the PR and between 780bbe3 and 2676430.

📒 Files selected for processing (20)
  • docs/en/commands/index.md
  • docs/en/commands/inspect.md
  • docs/en/commands/wait.md
  • docs/en/guide/advanced/fast-startup.md
  • docs/zh/commands/index.md
  • docs/zh/commands/inspect.md
  • docs/zh/commands/run.md
  • docs/zh/commands/wait.md
  • docs/zh/guide/advanced/fast-startup.md
  • src/commands/run/run.rest-primary.test.ts
  • src/commands/run/run.ts
  • src/commands/shared/clientSurfaceAttachment.test.ts
  • src/commands/shared/clientSurfaceAttachment.ts
  • src/commands/wait/index.ts
  • src/commands/wait/wait.test.ts
  • src/commands/wait/wait.ts
  • src/transport/http/routes/apiRoutes.test.ts
  • src/transport/http/routes/inspectRoutes.ts
  • test/e2e/commands/inspect.test.ts
  • test/unit-utils/MockFactories.ts
🚧 Files skipped from review as they are similar to previous changes (13)
  • docs/en/commands/index.md
  • docs/zh/commands/index.md
  • src/commands/shared/clientSurfaceAttachment.test.ts
  • src/commands/wait/index.ts
  • docs/zh/commands/inspect.md
  • docs/zh/commands/run.md
  • docs/zh/commands/wait.md
  • src/commands/run/run.rest-primary.test.ts
  • docs/en/commands/wait.md
  • docs/en/commands/inspect.md
  • docs/en/guide/advanced/fast-startup.md
  • src/commands/run/run.ts
  • src/transport/http/routes/inspectRoutes.ts

@@ -165,140 +72,38 @@ npx -y @1mcp/agent --config mcp.json --enable-async-loading \

有关选项的完整列表,请参阅 **[配置深入探讨](/guide/essentials/configuration#loading-section-async-loading)**。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use the Chinese locale prefix in this internal link.

This page is under docs/zh/, but the link targets the English route.

Proposed fix
-[配置深入探讨](/guide/essentials/configuration#loading-section-async-loading)
+[配置深入探讨](/zh/guide/essentials/configuration#loading-section-async-loading)

As per coding guidelines, Chinese content is served from /zh/ paths, with locale navigation configured in .vitepress/config/en.ts and .vitepress/config/zh.ts.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
有关选项的完整列表,请参阅 **[配置深入探讨](/guide/essentials/configuration#loading-section-async-loading)**
有关选项的完整列表,请参阅 **[配置深入探讨](/zh/guide/essentials/configuration#loading-section-async-loading)**
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/zh/guide/advanced/fast-startup.md` at line 73, Update the internal
configuration link in the Chinese fast-startup guide to use the `/zh/` locale
prefix, while preserving the existing configuration section anchor and link
text.

Source: Coding guidelines

@xizhibei
xizhibei merged commit 9696676 into main Aug 2, 2026
12 checks passed
@xizhibei
xizhibei deleted the codex/issues-async-395-405 branch August 2, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant